	<%@page import="java.sql.*"%>
	<%@page import=" java.security.MessageDigest"%>
	 
	<html>
	    <body>
	 
	    <%
	     
	    String username=request.getParameter("user");
	    String password=request.getParameter("pass");
	    String name=request.getParameter("name");
	    String phone=request.getParameter("phone");
	    int ph=Integer.parseInt(phone);
	    byte[] unencodedPassword = password.getBytes();
	    MessageDigest md = null;
	 
	    try {
	        md = MessageDigest.getInstance("MD5");
	    } catch (Exception e) {
	 
	        //Good practise for error handling by printing the Exception
	        %>
	        <%=e%>
	        <%
	    }
	 
	    //encoding the password
	 
	    md.reset();
	    md.update(unencodedPassword);
	    byte[] encodedPassword = md.digest();
	    StringBuffer buf = new StringBuffer();
	 
	    for (int i = 0; i < encodedPassword.length; i++) {
	        if (((int) encodedPassword[i] & 0xff) < 0x10) {
	            buf.append("0");
	        }
	        buf.append(Long.toString((int) encodedPassword[i] & 0xff, 16));
	    }
	 
	    String passw=buf.toString();
	    Connection con=null;
	 
	    //Create a database named "test" and table "details" in mySQL
	    //user name= root
	    //password= admin
	 
	    try{
	 
	    Class.forName("org.gjt.mm.mysql.Driver").newInstance();
	    con =DriverManager.getConnection("jdbc:mysql:///test","root","admin");
	    }
	    catch(Exception e){
	        %>
	        <%=e.toString()%>
	        <%
	    }
	 
	    try{
	        PreparedStatement ps = con.prepareStatement("INSERT INTO details(user,pass,name,phone) VALUES(?,?,?,?)");
	        ps.setString(1,username);
	        ps.setString(2,passw);
	        ps.setString(3,name);
	        ps.setInt(4,ph);
	        int i = ps.executeUpdate();
	 
	        ps.close();
	        con.close();
	    }
	    catch(Exception e){
	 
	        %>
	        <%=e.toString()%>
	        <%
	    }
	 
	        %>  
	    </body>
	</html>
